package com.zhoux.reflect;

/**
 * @author taoyi
 * @version 1.0
 * @date 2021/3/13 20:27
 *
 * 本类是测试通过反射访问构造方法的类
 */
public class Example_01 {
    String s;
    int i;
    int i2;
    int i3;
    private Example_01(){
    }

    protected Example_01(String s, int i) { // 该构造方法为protected，该构造方法不能直接创建对象，只能创建子类
        this.s = s;
        this.i = i;
    }

    public Example_01(String... strings) throws NumberFormatException{
        if (0 < strings.length)
            i = Integer.valueOf(strings[0]);
        if (1 < strings.length)
            i2 = Integer.valueOf(strings[1]);
        if (2 < strings.length)
            i3 = Integer.valueOf(strings[2]);
    }

    public void print(){
        System.out.println("s="+s);
        System.out.println("i="+i);
        System.out.println("i2="+i2);
        System.out.println("i3="+i3);
    }
}

